package com.apt.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.apt.common.AptException;
import com.apt.common.DBUtility;
import com.apt.model.ForgotPwd;

public class RoleMasterDao extends BaseConnection {

	public RoleMasterDao(Connection con) {

		super(con);

	}

	public String getRoleName(int roleId) throws AptException

	{
		String roleName=null;

		try {

			PreparedStatement ps = connection
					.prepareStatement("SELECT NAME FROM ROLE_MASTER WHERE ROLE_ID=?");
			ps.setInt(1, roleId);

			ResultSet rs = ps.executeQuery();
			while (rs.next()) {

				roleName = rs.getString(1);

			}
			rs.close();

		} catch (SQLException sqlEx) {
			sqlEx.printStackTrace();
			throw new AptException("Unable to get RoleName for RoleId:"
					+ roleId);

		} finally {
			DBUtility.cleanUp(connection);

		}

		return roleName;

	}

}
